import { ORDER_LIST, ORDER_CONFIRM, ORDER_SUBMIT, ORDER_INFO,
         ORDER_CANCEL, ORDER_PAY, ORDER_SETTLEMENT, ORDER_DELETE, ORDER_AS_CREATE, ORDER_AS_LIST, ORDER_LOGISTICS} from '@constants/order'
import { API_ORDER_LIST, API_ORDER_CONFIRM, API_ORDER_SUBMIT, API_ORDER_INFO,
         API_ORDER_CANCEL, API_ORDER_PAY, API_ORDER_SETTLEMENT, API_ORDER_DELETE, API_ORDER_AS_CREATE, API_ORDER_AS_LIST, API_ORDER_LOGISTICS } from '@constants/api'
import { createAction } from '@utils/redux'

/**
 * 订单列表
 * @param {*} payload
 */
export const dispatchOrderList = payload => createAction({
  url: API_ORDER_LIST,
  type: ORDER_LIST,
  payload
})

/**
 * 订单结算页
 * @param {*} payload
 */
export const dispatchOrderSettlement = payload => createAction({
  url: API_ORDER_SETTLEMENT,
  type: ORDER_SETTLEMENT,
  method: 'POST',
  payload
})

/**
 * 提交订单
 * @param {*} payload
 */
export const dispatchOrderSubmit = payload => createAction({
  url: API_ORDER_SUBMIT,
  method: 'POST',
  type: ORDER_SUBMIT,
  payload
})

/**
 * 取消订单
 * @param {*} payload
 */
export const dispatchOrderCancel = payload => createAction({
  url: API_ORDER_CANCEL,
  type: ORDER_CANCEL,
  payload
})

/**
 * 订单付款
 * @param {*} payload
 */
export const dispatchOrderPay = payload => createAction({
  url: API_ORDER_PAY,
  type: ORDER_PAY,
  payload
})

/**
 * 确认订单
 * @param {*} payload
 */
export const dispatchOrderConfirm = payload => createAction({
  url: API_ORDER_CONFIRM,
  type: ORDER_CONFIRM,
  payload
})

/**
 * 删除订单
 * @param {*} payload
 */
export const dispatchOrderDelete = payload => createAction({
  url: API_ORDER_DELETE,
  type: ORDER_DELETE,
  payload
})

/**
 * 订单详情
 * @param {*} payload
 */
export const dispatchOrderInfo = payload => createAction({
  url: API_ORDER_INFO,
  type: ORDER_INFO,
  payload
})

/**
 * 订单物流查看
 * @param {*} payload
 */
export const dispatchOrderLogistics = payload => createAction({
  url: API_ORDER_LOGISTICS,
  type: ORDER_LOGISTICS,
  payload
})

/**
 * 服务单提交
 * @param {*} payload
 */
export const dispatchServiceOrderSubmit = payload => createAction({
  url: API_ORDER_AS_CREATE,
  method: 'POST',
  type: ORDER_AS_CREATE,
  payload
})

/**
 * 服务单提交
 * @param {*} payload
 */
export const dispatchServiceOrderList = payload => createAction({
  url: API_ORDER_AS_LIST,
  type: ORDER_AS_LIST,
  payload
})
